<?php
header("Content-Type: text/html; charset=utf-8");
require_once '../smarty/Smarty.class.php';
require_once '../lib/pagination.php';
require_once '../lib/query_railway.php';
require_once '../lib/base.php';
$user=$_SESSION["RU"];
//var_dump($user);
if(!$user)header("Location:../user/login.php"); 
if($user["nick"]!="admin")exit;
if($_POST["act"]=="del") {
	$str="id=".$_POST["i"];
	$op= QR::del_data($tb_user,$str);
	if($op>0)echo "100" ;else echo "删除失败！或许数据已经被删除！";
	exit;
}
$p=($_GET["p"]==null)|($_GET["p"]==0) ?1:$_GET["p"];
$PAGE_NUM=15;
$from=($p-1)*$PAGE_NUM;

$name=htmlspecialchars( $_GET["n"]);
$str=" id>0";
if($name)$str.=" and name like '%$name%'";

$dbtable =$tb_user;
$count=QR::get_total($dbtable, $str);//all_number
//echo "<br/>".$count."<br/>";
$field="*";
$str.=" order by status";
$data=QR::get_data($dbtable, $field,$str,$from,$PAGE_NUM);//all_data
//var_dump($data);

$smarty = new Smarty;
$smarty->assign("userdata",$data);
$smarty->assign("pagination", getPageNavigation($p,$count,$PAGE_NUM));
$smarty->assign("name",$name);
$smarty->assign("user",$user);
$smarty->display('user_list.tpl');
function get_status($s){
	if($s=="true")return '<font color="blue">已通过</font>';
	if($s=="false")return '<font color="red">未通过</font>';
	return '<font color="#555">未审核</font>';
}
?>